﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GUI
{
    public partial class FormDanhSachDangKy : Form
    {
        public FormDanhSachDangKy()
        {
            InitializeComponent();
        }

        private void FormDanhSachDangKy_Load(object sender, EventArgs e)
        {
            this.dgvDanhSachDangKy.DataSource = DangKyBUS.SelectALLDangKy();         
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            DateTime NgayDi = dtpNgayDi.Value;
            NgayDi = NgayDi.Date;
            this.dgvDanhSachDangKy.DataSource = DangKyBUS.SelectALLDangKyByNgayDi(NgayDi);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            int row = dgvDanhSachDangKy.CurrentRow.Index;
            String MaNV = dgvDanhSachDangKy.Rows[row].Cells[0].Value.ToString();
            String ngay = dgvDanhSachDangKy.Rows[row].Cells[1].Value.ToString();
            DateTime NgayDi = DateTime.Parse(ngay);
            String MaChuyen = dgvDanhSachDangKy.Rows[row].Cells[2].Value.ToString();
            
            int kq = DangKyBUS.XoaDangKy(MaNV, NgayDi, MaChuyen);
            if (kq == 1)
            {
                MessageBox.Show("Xóa thành công");
                this.FormDanhSachDangKy_Load(null, null);
            }
            else
                MessageBox.Show("Xóa thất bại");
        }

       

    }
}
